package datastructure.sort;

public class BubbleSort extends AbstractArray {

	public BubbleSort(int max) {
		super(max);
	}

	@Override
	public void sort() {
		bubbleSort();		
	}
	
	public void bubbleSort() {
		int out, in;
		for (out = nElems - 1; out > 1; out--)
			// outer loop (backward)
			for (in = 0; in < out; in++)
				// inner loop (forward)
				if (a[in] > a[in + 1])
					swap(in, in + 1);
	} // end bubbleSort()


	public static void main(String[] args) {
		
		BubbleSort arr = new BubbleSort(maxSize); 
		arr.insert(77);
		arr.insert(99);
		arr.insert(44);
		arr.insert(55);
		arr.insert(22);
		arr.insert(88);
		arr.insert(11);
		arr.insert(00);
		arr.insert(66);
		arr.insert(33);
		
		System.out.println("Input Array: ");
		arr.display();

		arr.sort();

		System.out.println("\nAfter Bubble sort: ");
		arr.display();
	} // end main()
	
}
